import $ from '../common';
Page({
  data: {
    titleHeight: $.gData().titleHeight,
    statuHeight: $.gData().statuHeight,
    isIphoneX:$.gData().isIphoneX,
    info:[],
    _components_modal_hide:true,
    page:1,
    tip:'下拉加载更多'
  },
  getinfo(){
    const{page,group_uuid,info}=this.data
    $.get('/group/growing',{
      limit:20,
      page:page,
      group_uuid:group_uuid
    },res=>{
      if(res.growings.length==20){
        this.data.tip='下拉加载更多'
      }else{
        this.data.tip='已经到底了'
      }
      this.data.page++
      this.setData({
        info:[...info,...res.growings],
        tip:this.data.tip,
        campus_uuid:info.length>0?info[0].campus_uuid:res.growings[0].campus_uuid
      })
    })
  },
  onReachBottom(){
    console.log('触底了！！！');
    this.getinfo()
  },
  newbuild(){//新建点评点击打开模态框
    this.setData({
      _components_modal_hide:false
    })
  },
  cancel(){//取消点评关闭模态框
    this.setData({
      _components_modal_hide:true
    })
  },
  godrafter(e){//去往详情
    let {growing_uuid}=e.currentTarget.dataset
    $.navigateTo(`/Signin/draftreview?group_uuid=${this.data.group_uuid}&growing_uuid=${growing_uuid}&campus_uuid=${this.data.campus_uuid}`)
  },
  determine(e){//模态框的确定事件
   this.cancel() 
   $.navigateTo(`/Signin/draftreview?group_uuid=${this.data.group_uuid}&iscreate='YES'`)
  },
  onLoad(e) {
    const {group_uuid}=e
    this.setData({
      group_uuid
    })
    this.getinfo()
  },
  onShow(){},
})